package com.example.controller;

import com.example.domain.PageResult;
import com.example.domain.ResponseResult;
import com.example.domain.entity.User;
import com.example.domain.vo.UserVo;
import com.example.service.UserService;
import org.springframework.web.bind.annotation.*;

/**
 * @author hlc
 * @version 1.0
 * @date 2022/10/22 8:55
 */
@RestController
@RequestMapping("/user")
public class UserController {
    private final UserService userService;

    public UserController(UserService userService) {
        this.userService = userService;
    }

    @GetMapping("/{pageNumber}/{pageSize}")
    public ResponseResult<PageResult<UserVo>> getUserList(@PathVariable Integer pageNumber, @PathVariable Integer pageSize) {
        return userService.getUserPage(pageNumber, pageSize);
    }

    @DeleteMapping("/{userId}")
    public ResponseResult<?> deleteUser(@PathVariable Long userId) {
        return userService.deleteUser(userId);
    }

    @DeleteMapping("/{ids}")
    public ResponseResult<?> deleteUsers(@PathVariable Long[] ids) {
        return userService.deleteUsers(ids);
    }

    @PutMapping
    private ResponseResult<?> updateUser(@RequestBody User user) {
        System.out.println(user);
        return null;
    }
}
